@echo off
echo ========================================
echo      Docker容器测试脚本
echo ========================================
echo.

echo [1] 检查Docker服务状态...
docker --version
if %errorlevel% neq 0 (
    echo ❌ Docker服务未运行
    pause
    exit /b 1
)
echo ✅ Docker服务正常

echo.
echo [2] 停止并删除旧容器...
docker stop unitechoose9 2>nul
docker rm unitechoose9 2>nul
echo ✅ 旧容器已清理

echo.
echo [3] 构建新镜像...
docker build -f Dockerfile.simple -t liured88/unitechoose9 .
if %errorlevel% neq 0 (
    echo ❌ 镜像构建失败
    pause
    exit /b 1
)
echo ✅ 镜像构建成功

echo.
echo [4] 启动容器...
docker run -d --name unitechoose9 -p 7605:8000 -v D:\docker\unitechoose\data:/app/data --restart unless-stopped liured88/unitechoose9
if %errorlevel% neq 0 (
    echo ❌ 容器启动失败
    pause
    exit /b 1
)
echo ✅ 容器启动成功

echo.
echo [5] 等待容器启动...
timeout /t 5 /nobreak >nul

echo.
echo [6] 检查容器状态...
docker ps | findstr unitechoose9
echo.

echo [7] 查看容器日志...
docker logs unitechoose9
echo.

echo [8] 测试应用访问...
echo 正在测试 http://localhost:7605 ...
curl -s -o nul -w "HTTP状态码: %%{http_code}" http://localhost:7605
echo.

echo.
echo ========================================
echo           测试完成！
echo ========================================
echo 如果看到HTTP状态码200，说明部署成功
echo 访问地址: http://localhost:7605
echo 查看日志: docker logs -f unitechoose9
echo ========================================

pause
